//
//  File.js
//  jscsh
//
//  Created by Jonathan Hohle on 1/9/08.
//  Copyright 2008 hohle.net. All rights reserved.
//

File.Separator = File.PATH_SEPARATOR = File.SEPARATOR;

File.basename = function(fileName, suffix) {
}

File.catname = function(from, to) {
}

File.expandPath = function(fileName, dirString) {
}

File.FNM_CASEFOLD = 1;
File.FNM_PATHNAME = 2;
File.FNM_NOESCAPE = 4;

File.fnmatch = File.fileNameMatch = function(pattern, path, flags) {
/*
    var newPattern = pattern;
    var parsedPattern = null;
    
    do {
        print('parsedPattern: ' + parsedPattern);
        parsedPattern = newPattern;
    } while (newPattern != parsedPattern); */
    
    var parsedPattern = '^' + pattern.replace(/\//g, '\\/').
        replace(/\*\*/g, '(\\/[^\\/]+)*').
        replace(/\*/g, '[^\\/]+').
        replace(/((?!\\))\?/g, '$1.') + '$';
    
    parsedPattern = '^' + parsedPattern + '$';
    
    // print('parsedPattern: ' + parsedPattern);
    
    var regexp = new RegExp(parsedPattern);
    
    return (path.match(regexp) != null);
}

File.install = function(from, to, mode, verbose) {
}

File.join = function() {
}

File.split = function() {
}

